package com.itheima.mapper;

import com.itheima.pojo.Brand;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author tongchen
 * @create 2022-11-30 0:26
 */
public interface BrandMapper {
    //获取数据库连接
    @Select("select * from tb_brand")
    @ResultMap("brandResultMap")
    public List<Brand> selectAll();
    @Insert("insert into tb_brand values(null,#{brandName},#{companyName},#{ordered},#{description},#{status})")
    public void add(Brand brand);
    //回显功能的实现
    @Select("select *from tb_brand where id=#{id}")
    //解决映射问题
    @ResultMap("brandResultMap")
    public Brand selectById(int id);
    //修改功能的实现
    @Select("update tb_brand brand_name= #{brandName},company_name= #{companyName},ordered= #{ordered},description= #{description},status= #{status} where id= #{id}")
    public void update(Brand brand);
}
